package com.huawei.hms.framework.network.restclient.hwhttp.okhttp;

import com.huawei.hms.framework.common.CreateFileUtil;
import com.huawei.hms.framework.network.restclient.hwhttp.HttpClient;
import com.huawei.hms.framework.network.restclient.hwhttp.RequestTask;
import com.huawei.hms.framework.network.restclient.hwhttp.RequestTask.Factory;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.RCDns;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import o.ftw;
import o.fuj;
import o.fuv;
import o.fuv.b;

public class OkRequestTaskFactory implements Factory {
    private fuv okHttpClient;

    class OkDns implements fuj {
        private RCDns rcDns;

        OkDns(RCDns rCDns) {
            this.rcDns = rCDns;
        }

        public List<InetAddress> lookup(String str) throws UnknownHostException {
            return this.rcDns.lookup(str);
        }

        public boolean equals(Object obj) {
            return (obj instanceof OkDns) && this.rcDns.equals(((OkDns) obj).rcDns);
        }

        public int hashCode() {
            return this.rcDns.hashCode();
        }
    }

    public OkRequestTaskFactory(HttpClient httpClient) {
        b ॱ = OkHttpClientGlobal.getInstance().getClient().ˉ().ˊ(httpClient.getHostnameVerifier()).ˎ((long) httpClient.getConnectTimeout(), TimeUnit.MILLISECONDS).ˊ((long) httpClient.getReadTimeout(), TimeUnit.MILLISECONDS).ˏ((long) httpClient.getPingInterval(), TimeUnit.MILLISECONDS).ॱ(new OkDns(httpClient.getDns()));
        if (!(httpClient.getSslSocketFactory() == null || httpClient.getTrustManager() == null)) {
            ॱ.ॱ(httpClient.getSslSocketFactory(), httpClient.getTrustManager());
        }
        if (httpClient.getCache() != null) {
            ॱ.ˋ(new ftw(CreateFileUtil.newFile(httpClient.getCache().getCacheDir() + "/okhttp"), httpClient.getCache().getMaxSize()));
        }
        this.okHttpClient = ॱ.ˋ();
    }

    public RequestTask newTask() {
        return new OkRequestTask(this.okHttpClient);
    }
}
